package source.s02.synBlockString.service;

public class Service {

	private String usernameParam;
	private String passwordParam;
	//String anyString = new String();//同步-同一个对象
	public void setUsernamePassword(String username, String password) {
		try {
			String anyString = new String();//异步-不同对象
			//同步代码块非this对象和同步方法--异步
			//非this对象不是同一个对象，也是异步
			synchronized (anyString) {
				System.out.println("ssss1-" + Thread.currentThread().getName()
						+ "-ee-" + System.currentTimeMillis() + "-dd");
				usernameParam = username;
				Thread.sleep(3000);
				passwordParam = password;
				System.out.println("sss22-" + Thread.currentThread().getName()
						+ "-ee-" + System.currentTimeMillis() + "-dd");
			}
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
